package cn.bonoon.kernel.bytecode.asm;

import javax.persistence.EntityManager;

import cn.bonoon.kernel.exceptions.KeywordCheckException;

public abstract class WriterUtil {
	private WriterUtil(){}
	public static void check(String value, String[] keys){
		for(int i = 0; i < keys.length; i++){
			if(value.equals(keys[i])) 
				throw new KeywordCheckException(value);
		}
	}
	public static void check(EntityManager manager, String value, String ql){
		if(manager.createQuery(ql, Integer.class)
				.setParameter(1, value)
				.getSingleResult()
				.intValue() > 0)
			throw new KeywordCheckException(value);
	}
}
